<?php

class OptionsPermalinkController extends Controller {
    var $name = 'OptionsPermalink';
    var $uses = array('Options');
    var $components = array('options');
    
    function index() {
        $this->action = 'options_permalink';
        $this->options_permalink();
    }
    
    function options_permalink($status = null) {
        if (!empty($this->data['Options']['url_model'])) {
            update_option('url_model', $this->data['Options']['url_model']);
            $this->redirect('/options_permalink/options_permalink/update_done');
            exit();
        }
        if ($status == 'update_done') {
            $this->header_notice = __('Options saved.');
        }
        $option = $this->Options->find("`option_name`='url_model'", array('option_value'));
        if (empty($option->option_value)) {
            $option->option_value = 'default';
        }
        $this->data['Options']['url_model'] = $option->option_value;
    }
}

?>
